#!/bin/bash

# 测试批量操作API
echo "======================================"
echo "测试审计日志批量操作API"
echo "======================================"
echo ""

# 配置
API_URL="http://localhost:8000/api"
TOKEN="YOUR_TOKEN_HERE"  # 请替换

# 检查token
if [ "$TOKEN" = "YOUR_TOKEN_HERE" ]; then
    echo "⚠️  请在脚本中配置 TOKEN"
    echo "   可以从浏览器 localStorage.getItem('token') 获取"
    echo ""
    echo "继续测试（可能会401错误）..."
    echo ""
fi

echo "1. 测试批量解决API路由"
echo "================================"
curl -X POST "$API_URL/audit-logs/bulk_resolve/" \
  -H "Authorization: Token $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"ids": []}' \
  -w "\nHTTP状态码: %{http_code}\n" \
  -s
echo ""

echo ""
echo "2. 测试批量删除API路由"
echo "================================"
curl -X POST "$API_URL/audit-logs/bulk_delete/" \
  -H "Authorization: Token $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"ids": []}' \
  -w "\nHTTP状态码: %{http_code}\n" \
  -s
echo ""

echo ""
echo "3. 测试错误的HTTP方法（应该返回405）"
echo "================================"
curl -X GET "$API_URL/audit-logs/bulk_resolve/" \
  -H "Authorization: Token $TOKEN" \
  -w "\nHTTP状态码: %{http_code}\n" \
  -s
echo ""

echo ""
echo "======================================"
echo "测试完成"
echo "======================================"
echo ""
echo "💡 说明:"
echo "  - 200: 成功"
echo "  - 400: 参数错误（正常，因为ids为空）"
echo "  - 401: 未授权（需要配置TOKEN）"
echo "  - 404: 路由不存在"
echo "  - 405: HTTP方法不允许"
